<template>
  <div @click="$router.push({ name: 'detail', params: { id: 15 } })" :class="`pro-card ${ $route.name == 'home' ? 'is_home' : $route.name == 'detail' ? 'detail-order' : $route.name == 'profile_love' ? 'is_profile_love' : 'not_home' }`" :data-aos="$route.name == 'home' ? 'fade-down' : ''" class="">
    <div class="card-img">
      <img :src="item.img" alt="">
    </div>
    <div class="card-quality">{{ item.brand }}</div>
    <div class="card-name">{{ item.name }}</div>
    <div class="card-price">{{ item.price }}</div>

    <div v-if="$route.name != 'profile_love'" @click.stop class="icon-love">
      <img src="/img/love.png" alt="">
    </div>
    <div v-if="$route.name  != 'profile_love'" @click.stop class="icon-cart">
      <img src="/img/cart.png" alt="">
    </div>
    <div v-else @click.stop class="icon-love">
      <!-- <img src="/img/love.png" alt=""> -->
       <el-icon color="red" size="20">
        <Delete />
       </el-icon>
    </div>
  </div>
</template>

<script setup lang="ts">
import AOS from 'aos'
import { onMounted } from 'vue'

defineProps(['item'])

onMounted(() => {
  AOS.init({
    offset: 273,
    duration: 800,
    once: false,
    disable: 'mobile'
  })
})
</script>

<style lang="less" scoped>
.not_home {
  height: 470px;
  width: 262px;
  margin-right: 89px;

  .card-img {
    height: 330px;
    transition: all 0.4s;
    box-sizing: border-box;
    border: 1px solid #e9eaea;
  }

  .card-quality {
    margin-top: 10px;
  }
}

.is_profile_love {
  width: 30%;

  .card-img {
    height: 330px;
    transition: all 0.4s;
    box-sizing: border-box;
    border: 1px solid #e9eaea;
  }

  .card-quality {
    margin-top: 10px;
  }
}

.detail-order {
  height: 470px;
  width: 262px;

  .card-img {
    height: 330px;
    transition: all 0.4s;
    box-sizing: border-box;
    border: 1px solid #e9eaea;
  }

  .card-quality {
    margin-top: 10px;
  }
}

// 把倒数第三个元素以及之后的元素都排除
.is_profile_love:not(:nth-last-child(-n+3)) {
  margin-bottom: 30px;
}

.not_home:nth-child(3n) {
  margin-right: 0;
}

.is_home {
  height: 390px;
  width: calc(100% / 4);
  transition: all 0.4s;

  .card-img {
    height: 260px;

    img {
      height: 100%;
      width: 80%;
    }
  }
}

.pro-card {
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  cursor: pointer;

  .card-img {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .card-quality {
    color: rgb(20, 28, 29);
    font-family: Epilogue;
    font-size: 16px;
    font-weight: 400;
    line-height: 30px;
    margin-left: 25px;
  }

  .card-name {
    color: rgb(20, 28, 29);
    font-family: Epilogue;
    font-size: 16px;
    font-weight: 700;
    line-height: 30px;
    margin: 10px 0;
    margin-left: 25px;
  }

  .card-price {
    color: rgb(20, 28, 29);
    font-family: Epilogue;
    font-size: 16px;
    font-weight: 400;
    line-height: 30px;
    margin-left: 25px;
  }

  .icon-love {
    position: absolute;
    width: 40px;
    height: 40px;
    background-color: #fff;
    border-radius: 50%;
    top: 18px;
    right: -50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;

    img {
      width: 21px;
      height: 21px;
    }
  }

  .icon-cart {
    position: absolute;
    width: 40px;
    height: 40px;
    background-color: #fff;
    border-radius: 50%;
    top: 75px;
    right: -50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;

    img {
      width: 21px;
      height: 21px;
    }
  }
}

.is_home:not(:nth-child(4n)) {
  border-right: 1px solid rgba(20, 28, 29, 0.1);
}

.is_home:nth-child(n + 5) {
  border-top: 1px solid rgba(20, 28, 29, 0.1);
}

.is_home:hover {
  background-color: #A3AAAB1A;

  .icon-love {
    right: 18px;
  }

  .icon-cart {
    right: 18px;
  }
}

.detail-order:hover {
  .card-img {
    background-color: #A3AAAB1A;
  }

  .icon-love {
    right: 18px;
  }

  .icon-cart {
    right: 18px;
  }
}

.not_home:hover {
  .card-img {
    background-color: #A3AAAB1A;
  }

  .icon-love {
    right: 18px;
  }

  .icon-cart {
    right: 18px;
  }
}

.is_profile_love:hover {
  .card-img {
    background-color: #A3AAAB1A;
  }

  .icon-love {
    right: 18px;
  }

  .icon-cart {
    right: 18px;
  }
}
</style>